home *** CD-ROM | disk | FTP | other *** search
- /* btclose */
- #include <stdio.h>
- #include <btextern.h>
- int btclose (filhand)
-
- unsigned filhand;
-
- /* close a file and free buffers */
- {
- char *cp;
- int i;
-
- /* make sure file is open */
- if (btfilar[filhand].handle == NULL)
- BTSETCOD (filhand, NULL, 61); /* file not open */
-
- /* write index info record it may have changed */
-
- /* move new root value to info index record before close */
-
- *(btfilar[filhand].infobuf) = btfilar[filhand].root;
- movmem (btfilar[filhand].infobuf,
- btfilar[filhand].filbuf, LBLEN);
- if ((i = btwrit (filhand, 0)))
- BTSETCOD (filhand, 0, i);
-
- /* free index info buffer */
- cp = (char *)btfilar[ filhand].infobuf;
- free (cp);
-
- /* free root record buffer */
- cp = (char *)btfilar[ filhand].filbuf;
- free (cp);
-
- /* free control block */
- btfilar[filhand].handle = NULL;
-
- /* close file */
- fclose (btfilar[ filhand].fdesc);
- return (0);
- }
- /* end of btclose */